/**
 * @file: service.js
 * @description:
 * @author： YUWENJING
 * @date： 2020/2/16
 * @contact: wenjingyuer@126.com
 */

import Taro from '@tarojs/taro'
import {redirectWithAuth, toast} from "../../../../utils";
import {getGlobalData, setGlobalData} from "../../../../global.d";
import {getUserById} from "../../../../service";

const db = Taro.cloud.database();
const _ = db.command
/**
 * @description: 更新班级信息
 * @param classId
 * @param classInfo
 * @author: YUWENJING
 * @date: 2020/2/15
 */
export async function updateClassInfo(classId,classInfo) {

  db.collection('class')
    .doc(classId)
    .update({
      data:{
        classInfo
      },
      success:async res => {
        let userId = getGlobalData('userId')
        let user = await getUserById(userId)
        setGlobalData(user)
        toast('操作成功')
        Taro.navigateBack()
      }
    })
}




